package com.wenhao.leetcode.easy;

/**
 * 题目：https://leetcode-cn.com/problems/plus-one/
 * 加一
 *
 * @author Wenhao Tong
 * @Description
 * @create 2021-07-01 18:40
 */
public class LeetCode66 {
    public static void main(String[] args) {

    }

    public int[] plusOne(int[] digits) {
        for (int i = digits.length - 1;i > -1;i--) {
            if (digits[i] < 9) {
                digits[i] += 1;
                return digits;
            } else {
                digits[i] = 0;
            }
        }
        int[] result = new int[digits.length + 1];
        result[0] = 1;
        return result;
    }
}
